<#import "../tpl/pageTep.ftl" as page>
<@page.pageBase currentMenu="关于我们">
<div class="xm-product">
    <div class="row">
        <div class="panel">
            <div class="panel-body">
                <form id="addForm" class="form-horizontal hide" action="${basepath}/rest/manage/aboutus/insertJson"
                      method="post">
                    <input type="hidden" name="id" >
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            公司名称：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="name"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            公司地址：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="companyAddress"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            工厂地址：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="factoryAddress"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8"
                                   data-rules="{required : true}"  name="contactPhone" >
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            技术支持：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8"
                                   data-rules="{required : true}" name="techonlogyPhone" >
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系人：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="linkman"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            手机号：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="linkmanPhone"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            传真：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="fax"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            网址：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="companyUrl"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            QQ：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="qq"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            邮箱：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="email"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="centered">
                        <button class="button  button-large  button-success add" type="submit">新增</button>
                    </div>
                </form>
                <form id="editform" class="form-horizontal" action="${basepath}/rest/manage/aboutus/updateJson"
                      method="post">
                    <input type="hidden" name="id" id="id">
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            公司名称：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="name" id="name"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            公司地址：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="companyAddress" id="companyAddress"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            工厂地址：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="factoryAddress" id="factoryAddress"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系电话：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8"
                                   data-rules="{required : true}"  name="contactPhone" id="contactPhone">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            技术支持：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8"
                                   data-rules="{required : true}" name="techonlogyPhone" id="techonlogyPhone">
                        </div>
                    </div>

                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            联系人：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="linkman" id="linkman"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            手机号：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="linkmanPhone" id="linkmanPhone"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            传真：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="fax" id="fax"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            网址：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="companyUrl"  id="companyUrl"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            QQ：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="qq" id="qq"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="control-group">
                        <label class="control-label">
                            <s>*</s>
                            邮箱：
                        </label>
                        <div class="controls">

                            <input type="text" class="control-text span-width span8" name="email"  id="email"
                                   data-rules="{required : true}">
                        </div>
                    </div>
                    <div class="centered">
                        <button class="button  button-large  button-success add" type="submit">保存</button></div>
                </form>
            </div>
        </div>
    </div>
</div>

<script type="text/javascript">
    var addForm = new BUI.Form.Form({
        srcNode: '#addForm',
        submitType: 'ajax',
        callback: function (data) {
            if (data.success == true) {
                window.location.reload()
            } else {
                BUI.Message.Alert(data.message, 'error');
                return;
            }
        }
    }).render();
    var editForm = new BUI.Form.Form({
        srcNode: '#editform',
        submitType: 'ajax',
        callback: function (data) {
            if (data.success == true) {
                window.location.reload()
            } else {
                BUI.Message.Alert(data.message, 'error');
                return;
            }
        }
    }).render();
    (function () {
        $.ajax({
            type:'GET',
            url:' /rest/manage/aboutus/selectAllList',
            async:false,
            dataType:'json',
            success:function (data) {
                var list=data.data[0],html='';
                if(list!=null&&list!=''){
                    $('#id').val(list.id);
                    $('#name').val(list.name);
                    $('#companyAddress').val(list.companyAddress);
                    $('#factoryAddress').val(list.factoryAddress);
                    $('#contactPhone').val(list.contactPhone);
                    $('#techonlogyPhone').val(list.techonlogyPhone);
                    $('#linkman').val(list.linkman);
                    $('#linkmanPhone').val(list.linkmanPhone);
                    $('#fax').val(list.fax);
                    $('#companyUrl').val(list.companyUrl);
                    $('#qq').val(list.qq);
                    $('#email').val(list.email);
                }else{
                    $('#editform').hide();
                    $('#addForm').show();
                }

            }
        })
    })();

</script>

</@page.pageBase>
